<template>
  <div>
    <Scroll class="content">
      <div v-for="(item, i) in goods" :key="i" class="goods-section">
        <div class="goods-header">
          <span>订单号:{{ item.orderId }}</span>
          <span>{{ item.state }}</span>
        </div>
        <div v-for="(it, index) in item.counts" :key="index" class="goods-section-item">
          <div class="goods-img">
            <img :src="item.imgUrls[index]" alt="">
          </div>
          <div class="goods-info">
            <h4>{{ item.titles[index] }}</h4>
            <div>￥{{ item.prices[index] }}</div>
            <div>X{{ item.counts[index] }}</div>
          </div>
        </div>
        <div class="goods-footer">
          <p>共<span>{{ item.counts.reduce((prev, item) => prev + parseInt(item), 0) }}</span>件产品, 总计：￥<span>{{
              item.totalPrice
          }}</span></p>
        </div>
      </div>
      <div style="height: 100px;"></div>
    </Scroll>
  </div>
</template>

<script>
import Scroll from '@/components/common/Scroll.vue';
export default {
  props: {
    goods: {
      type: Array,
      default() {
        return []
      }
    }
  },
  components: {
    Scroll
  }
}
</script>

<style scoped lang="less">
.content {
  height: 80vh;
  overflow: hidden;

  .goods-section {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;

    .goods-header {
      display: flex;
      height: 25px;
      font-size: 14px;
      color: #ccc;
      justify-content: space-between;

      span:nth-child(2) {
        color: #d92c36;
        font-size: 16px;
        font-weight: 700;
        margin-right: 15px;
      }
    }

    .goods-footer {
      position: relative;
      height: 30px;

      p {
        position: absolute;
        right: 20px;
        top: 5px;
        margin: 0;
        font-size: 14px;
        color: #9e9e9e;

        span:nth-child(1) {
          color: #999;
          font-size: 16px;
        }

        span:nth-child(2) {
          font-size: 16px;
          color: #d92c36;
        }
      }
    }

    .goods-section-item {
      display: flex;
      width: 100%;

      .goods-img {
        width: 75px;
        height: 75px;
        margin-right: 15px;

        img {
          width: 100%;
        }
      }

      .goods-info {
        h4 {
          margin: 0;
          font-size: 14px;
          font-weight: normal;
          margin-bottom: 15px;
        }

        div:nth-of-type(1) {
          color: #d92c36;
          font-size: 16px;
        }

        div:nth-of-type(2) {
          margin-top: 6px;
          margin-right: 10px;
          color: #666;
          font-size: 12px;
        }
      }
    }
  }
}
</style>

